package main

import (
	"fmt"
	"sync"
	"sync/atomic"
)

func main() {
	var atomicOps uint64 = 0
	var ops uint64 = 0

	var nThreads = 50
	var wg sync.WaitGroup
	wg.Add(nThreads)

	for i := 0; i < nThreads; i++ {
		go func() {
			for j := 0; j < 1000000; j++ {
				atomic.AddUint64(&atomicOps, 1)
				ops += 1
			}
			wg.Done()
		}()
	}

	wg.Wait()

	opsFinal := atomic.LoadUint64(&atomicOps)

	fmt.Println("ops : ", opsFinal, " vs ", ops)
}
